ARG CODE_SERVER_VER=latest
FROM codercom/code-server:${CODE_SERVER_VER}
USER root
ARG GO_VER PYTHON_VER NVM_VER NODE_VER

# apt
RUN apt update && apt install -y \
    python${PYTHON_VER} \
    python3-pip \
    wget \
    vim \
    zsh \
    htop \
    inetutils-ping && \
    rm -rf /var/lib/apt/lists/* && \
    apt autoremove --purge

# Golang
RUN wget https://dl.google.com/go/go${GO_VER}.linux-amd64.tar.gz && \
    tar -xvf go${GO_VER}.linux-amd64.tar.gz && \
    mv go /usr/local && \
    rm go${GO_VER}.linux-amd64.tar.gz

ENV GOROOT=/usr/local/go
ENV GOPATH=/home/coder/code-server/go
ENV PATH=$GOPATH/bin:$GOROOT/bin:$PATH

# Python3
RUN pip3 install pipenv pylint flake8 --break-system-packages

# Typescript
RUN curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v${NVM_VER}/install.sh | bash && \
    \. "$HOME/.nvm/nvm.sh" && \
    nvm install ${NODE_VER} && \
    npm install -g npm typescript ts-node nodemon

# zsh
RUN chsh -s /bin/zsh && \
    chown -R coder:coder /home/coder